package com.zjq.smartdevice.tasks;

import com.zjq.smartdevice.events.HumitureCheckEvent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @User zhangjiaqi
 * @Project project
 * @Package com.zjq.smartdevice.tasks
 * @Date 2022/3/27 21:24
 */
@Component
public class HumitureTask {

    private ApplicationContext context;

    @Autowired
    public void setContext(ApplicationContext context) {
        this.context = context;
    }

    @Scheduled(fixedRate = 60000)
    public void checkStatus() {
        //对最近的温度进行平均值的计算,做一些事情
        context.publishEvent(new HumitureCheckEvent());
    }
}
